home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / PlainTalk™ Speech Technologies / Text to Speech / Programming Stuff / Examples / SpeakFile / Globals.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-15  |  2.7 KB  |  70 lines  |  [TEXT/KAHL]

  1. #pragma once
  2.  
  3. #ifndef utypes
  4. #define utypes
  5.     typedef unsigned long     ulong;
  6.     typedef unsigned short     ushort;
  7. #endif utypes
  8.  
  9. struct GlobalsRecord {
  10.     WindowPtr        theWindow;                        // our window, of course
  11.     ulong            numLines;                        // number of lines of displayable text
  12.     ulong            textLen;                        // byte length of text data                    
  13.     Ptr                lines;                            // buffer of text bytes
  14.     ulong            *lineStarts;                    // array of byte ptrs corresponding to starts of each display line
  15.     ulong            curLine;                        // current line we should start display from
  16.     short            lineHeight;                        // line height for current font in pixels/line
  17.     short             displayLines;                    // number of display lines we can fit in the window
  18.     Boolean            idleTrigCalcs;
  19.     Boolean            idlePurgeCompact;
  20. };
  21.  
  22. typedef struct GlobalsRecord GlobalsRecord;
  23. typedef struct GlobalsRecord *GlobalsPtr;
  24.  
  25. extern GlobalsPtr        globals;
  26. extern char                gStr[];
  27. extern ushort            gStrLen;
  28. extern Boolean            gPrintFlag;
  29.  
  30. void    AddLineToTextDisplay(GlobalsPtr g, char *format, ulong value);
  31. void    AddStringToTextDisplay(GlobalsPtr g, char *format);
  32.  
  33. #define MIN(a,b) (((a) <= (b)) ? (a) : (b))
  34. #define MAX(a,b) (((a) >= (b)) ? (a) : (b))
  35. #define ABS(a) (((a) < 0) ? -(a) : (a))
  36.  
  37. #ifdef DEBUG
  38. #define ShowNum(label, num)        if (gPrintFlag) gStrLen += sprintf(&gStr[gStrLen],label,(num))
  39. #ifdef THINK_C
  40. #define ShowPStr(label, pstr)    if (gPrintFlag) gStrLen += sprintf(&gStr[gStrLen],label"\"%#s\"", (pstr))
  41. #else
  42. #define ShowPStr(label, pstr)    if (gPrintFlag) gStrLen += sprintf(&gStr[gStrLen],label"\"%.*s\"", (pstr)[0], &((pstr)[1]))
  43. #endif
  44. #define ShowOSType(label, type)    if (gPrintFlag) gStrLen += sprintf(&gStr[gStrLen],label"\'%.4s\'", &(type))
  45. #define ShowStr(label)            if (gPrintFlag) gStrLen += sprintf(&gStr[gStrLen],label)
  46. #define ShowLenStr(label,len)    if (gPrintFlag) gStrLen += sprintf(&gStr[gStrLen], "%.*s", (len), label)
  47. #define ShowCR()            if (gPrintFlag) {                            \
  48.                                 gStrLen += sprintf(&gStr[gStrLen]," ");    \
  49.                                 AddStringToTextDisplay(g, gStr);    \
  50.                                 gStrLen = 0;                            \
  51.                             }
  52. #define TabColumn(col)        if (gPrintFlag) {                                \
  53.                                 while (gStrLen < col)                        \
  54.                                     gStrLen += sprintf(&gStr[gStrLen]," ");    \
  55.                             }
  56. #else
  57. #define ShowNum(label, num)        ((void)0)
  58. #define ShowPStr(label, pstr)    ((void)0)
  59. #define ShowStr(label)            ((void)0)
  60. #define ShowLenStr(label, len)    ((void)0)
  61. #define ShowCR()                ((void)0)
  62. #define TabColumn(col)            ((void)0)
  63. #endif
  64.  
  65. #define ShowNumCR(label, num)        {ShowNum(label,num); ShowCR();}
  66. #define ShowPStrCR(label, pstr)        {ShowPStr(label, pstr); ShowCR();}
  67. #define ShowOSTypeCR(label, type)    {ShowOSType(label, type); ShowCR();}
  68. #define ShowStrCR(label)            {ShowStr(label); ShowCR();}
  69. #define ShowLenStrCR(label,len)        {ShowLenStr(label,len); ShowCR();}
  70.